function M = playStack(I,p,framerate,channels)
%% playStack.m
%framerate in frames/second

%% Default Arguments
if nargin<2
    p=1;
end
if nargin<3
    framerate=15;
end 
if nargin<4
    channels=[1 2 3];
end 

num_channels = size(I,1);
num_positions = size(I,2);
num_time = size(I{1,1},3);

%% Channels to RGB
%Note: assumes 1 = BF, 2 = GFP, 3 = mCherry

rgb = zeros(512,512,num_channels,num_time);
rgb(:,:,1,:) = any(channels==1)*mat2gray(I{1,p}) + any(channels==3)*mat2gray(I{3,p});
rgb(:,:,2,:) = any(channels==1)*mat2gray(I{1,p}) + any(channels==2)*mat2gray(I{2,p});
rgb(:,:,3,:) = any(channels==1)*mat2gray(I{1,p});
rgb(rgb>1)=1;

%% Display and Load to Movie
for t=1:num_time
        M(t) = im2frame(squeeze(rgb(:,:,:,t)));
end

imshow(rgb(:,:,:,1))
movie(M,1,framerate,[0 0 0 0])

end